<template>
  <div class="container">
    <topTitle
      :titleText="titleText"
      :back="true"
      @gobackTriser="goBack"
    ></topTitle>
    <div class="mainCon">
      <div class="info complainInfo">
        <p class="title">投诉信息</p>
        <el-row>
          <el-col>
            <el-row>
              <el-col :span="12" class="desc"
                >来源：{{ infoDetail.source }}</el-col
              >
              <el-col :span="12" class="desc"
                >投诉时间：{{ infoDetail.complainantTime }}</el-col
              >
            </el-row>
          </el-col>
          <el-col>
            <el-row>
              <el-col :span="12" class="desc"
                >投诉人：{{ infoDetail.complainant }}</el-col
              >
              <el-col :span="12" class="desc"
                >投诉人联系电话：{{ infoDetail.complainantPhone }}</el-col
              >
            </el-row>
          </el-col>
        </el-row>
        <el-row>
          <el-col class="desc"
            >投诉内容：{{ infoDetail.complainantDetail }}</el-col
          >
        </el-row>
        <el-row>
          <el-col class="desc">当前状态：{{ infoDetail.statusDesc }}</el-col>
        </el-row>
      </div>
      <div class="info progressInfo">
        <p class="title">办理记录</p>
        <div v-for="v in progressDetail" :key="v.id" class="infoBox">
          <div class="subBox">
            <span class="subTitle">夷陵一家亲</span>
            {{ v.dealTime }}
          </div>
          <div>
            <template v-if="v.dealType === 2">
              <p>回复人：{{ v.dealPerson }}</p>
              <p>回复内容：{{ v.dealContent }}</p>
            </template>
            <template v-else>
              <p>转交内容：{{ v.dealPerson }}</p>
              <p>转交说明：{{ v.dealContent }}</p>
            </template>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'familyComplainDetail',
  data() {
    return {
      titleText: '投诉详情',
      infoDetail: {},
      progressDetail: [],
    }
  },
  async mounted() {
    const { id, complaintCode } = this.$route.query
    await this.getInfoDetail(id)
    await this.getProgressDetail(complaintCode)
  },
  methods: {
    // 信息详情
    getInfoDetail(id) {
      return this.axios({
        method: 'post',
        url: 'api-c/complaint/base/detail',
        data: {
          id,
        },
      })
        .then((response) => {
          if (!response.data.hasError) {
            this.infoDetail = response.data.result
          } else {
            this.$message.error(response.data.errorMsg)
          }
        })
        .catch((error) => {
          if (error.response) {
            this.$message.error(error.response.data)
          }
        })
    },
    // 处理详情
    getProgressDetail(id) {
      return this.axios({
        method: 'post',
        url: 'api-c/complaint/deal/detail',
        data: {
          complaintCode: id,
        },
      })
        .then((response) => {
          if (!response.data.hasError) {
            this.progressDetail = response.data.result
          } else {
            this.$message.error(response.data.errorMsg)
          }
        })
        .catch((error) => {
          if (error.response) {
            this.$message.error(error.response.data)
          }
        })
    },
    //返回
    goBack() {
      this.$router.push('/home/unpaidComplaint/familyComplainList')
      this.$store.commit('GOBACK_NAME', {
        oldUrl: '/home/unpaidComplaint/familyComplainList',
        newUrl: this.$router.currentRoute.fullPath,
      })
    },
  },
}
</script>

<style lang="less" scoped>
.container {
  .mainCon {
    height: calc(100% - 67px);
    overflow-y: auto;
    padding: 24px;
    background: #f5f7fa;
    .info {
      padding: 24px;
      padding-bottom: 60px;
      background: #fff;
      .title {
        font: bold 18px Microsoft YaHei;
        color: #333333;
        border-left: 4px solid #009588;
        padding-left: 20px;
      }
      .desc {
        margin-top: 60px;
        padding-left: 20px;
        line-height: 20px;
      }
      .infoBox {
        margin-top: 20px;
        border-top: solid 1px #999;
        .subBox {
          margin-top: 20px;
          .subTitle {
            font: bold 18px Microsoft YaHei;
            line-height: 30px;
            margin-right: 40px;
            padding-left: 14px;
            position: relative;
            &::before {
              content: '';
              display: block;
              position: absolute;
              top: 7px;
              left: 0px;
              width: 8px;
              height: 8px;
              background: #009588;
              border-radius: 50%;
            }
          }
        }
        p {
          line-height: 28px;
        }
      }
    }
    .progressInfo {
      min-height: 200px;
      margin-top: 20px;
      padding-bottom: 20px;
    }
  }
}
</style>
